setTimeout(function(){
	html = ttCollectPanel();
	btn = shrinkBtn('头条面板');
	$('html body').append(btn);
	$('html body').append(html);
	
	
},1000);
/* 
头条条目采集 
 */
$('html body').on('click','.ttItemBtn',function () {
	that =  $('.tt_collect_process');
	wordsPrepend(that,'开始。。');
	
	it = setInterval(function(){
		// 获取contentid
		content_id = ttContentId();
		if(!content_id){
			wordsPrepend(that,'done',1);
			clearInterval(it);
		}
		res = ttDetail(content_id);
		if(res){
			result = ttItemSubmit(res);
			if(result){
				wordsPrepend(that,content_id,1);
			}else{
				wordsPrepend(that,content_id,2);
			}
		}
	},2000);	
})

/* 
头条列表采集 
 */
$('html body').on('click','.ttBtn',function () {
	that =  $('.tt_collect_process');
	wordsPrepend(that,'开始。。');
	keyword = $("input[name='keyword']").val()
	i = 0;
	inteval = setInterval(function(){
		data = searchList(keyword,i);
		content_ids = [];
		
		if(data.data.length > 0){
			for(item of data.data){
				console.log(item);
				if(item.hasOwnProperty('app_info')){
					app_info = item.app_info;
					if(app_info && app_info.hasOwnProperty('db_name')){
						if(app_info.db_name == 'SITE'){
							str = item.id;
							if(typeof(str)=='string'){
								if(str.substring(0,1) == '6'){
									content_ids.push(item.id);	
								}
							}
						}
					}
				}
				
				
			}
		}
		console.log(content_ids);
		res = ttContentIdSubmit(keyword,JSON.stringify(content_ids));
		if(res){
			wordsPrepend(that,'第'+ (i+1) + '页获取完成');
		}
		if(!data.has_more){
			wordsPrepend(that,'完成');
			clearInterval(inteval);
		}
		i++;
	},3000)
});